using System;
using System.Collections.Generic;
using FireStarterModeller.BO;
using FireStarterModeller.Logic;
using FireStarterModeller.Logic.Wizards;
using FireStarterModeller.UI.Relationship;
using Habanero.Faces.Base;
using Habanero.Faces.Win;
using Microsoft.Practices.Unity;

namespace FireStarterModeller.UI.Wizards
{
    public class DeleteDMClassWizardStep2 : WizardStepWin
    {
    }
    public class DeleteDMClassWizardStep3 : WizardStepWin
    {
    }
    public class DeleteDMClassWizardController : WizardController
    {
//        private readonly CreateRelationshipWizardStep1 _step1; //Select Related Class
//        private readonly CreateRelationshipWizardStep2 _step2; //Step Only used if FK in Owner or Related
        //Class does not have matching Foreign key props. User can select Cardinality of Rel and whether to 
        // Create related props or not.
//        private readonly CreateRelationshipWizardStep3 _step3; //Confirm what has been done for the
        // relationship.
//        private readonly CreateRelationshipWizardStep4 _step4; //Final Confirmation and any warnings.
        private readonly Stack<IWizardStep> _visitedSteps  = new Stack<IWizardStep>();
        private DeleteDMClassWizardStep1 Step1 { get; set; }
        private DeleteDMClassWizardStep2 Step2 { get; set; }
        private DeleteDMClassWizardStep3 Step3 { get; set; }
//        public DMRelationshipCreator RelationshipCreator { get; private set; }

        public DMClass ClassDM { get; private set; }

        public DeleteDMClassWizardController(DMClass dmClass)
        {
            if (dmClass == null) throw new ArgumentNullException("dmClass");
            ClassDM = dmClass;
             Step1 = new DeleteDMClassWizardStep1(new DMClassDeleter(dmClass));
             AddStep(Step1);

             if (this.ClassDM.HasRelationshipsWithRelatedFK)
             {
                 Step2 = new DeleteDMClassWizardStep2();
                 Step3 = new DeleteDMClassWizardStep3();

                 AddStep(Step2);
                 AddStep(Step3);
             }
        }

        public override IWizardStep GetPreviousStep()
        {
            _visitedSteps.Pop();
            IWizardStep previousStep = _visitedSteps.Peek();
            CurrentStep = WizardSteps.IndexOf(previousStep);
            return previousStep;
        }

/*        public override void CancelWizard()
        {
            base.CancelWizard();
            this.RelationshipCreator.CancelAllEdits();
        }*/
/*
        public override IWizardStep GetNextStep()
        {
            if (CurrentStep >= WizardSteps.Count - 1)
                throw new WizardStepException("Invalid Wizard Step: " + (CurrentStep + 1));

            if (GetCurrentStep() == _step1)
            {
                if (this.RelationshipCreator.CanFindForeignKey)
                {
                    //Skip step 2 and Setup Relationship
                    CurrentStep = WizardSteps.IndexOf(_step2);
                }
            }
            IWizardStep nextStep = base.GetNextStep();
            _visitedSteps.Push(nextStep);
            return nextStep;
        }*/

    }
}